﻿@{
    ViewBag.Title = "添加流程树";
    Layout = "~/Areas/Member/Views/Shared/_layer_layout.cshtml";
    List<SelectListItem> listApprovalTrees = ViewBag.ApprovalTrees;
}

<div class="fly-panel fly-panel-user" pad20="">
    <div class="layui-tab layui-tab-brief" lay-filter="user">
        <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding:10px 40px 10px 0;">
            @using (Html.BeginForm(FormMethod.Post, htmlAttributes: new { @class = "layui-form", id = "myForm" }))
            {
                @Html.AntiForgeryToken()

                <div class="layui-form-item">
                    <label class="layui-form-label" for="fromID">从原型</label>
                    <div class="layui-input-block">
                        <select name="fromID" id="fromID">
                            @foreach (SelectListItem item in listApprovalTrees)
                            {
                                <option value="@item.Value">@item.Text</option>
                            }
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label" for="fromID">复制到</label>
                    <div class="layui-input-block">
                        <select name="toID" id="toID">
                            @foreach (SelectListItem item in listApprovalTrees)
                            {
                                <option value="@item.Value">@item.Text</option>
                            }
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block" style="text-align:right;">
                        <input type="button" value="提 交" class="layui-btn" />
                    </div>
                </div>
            }
        </div>
    </div>
</div>
<script type="text/javascript">
    layui.use(['form', 'layedit', 'element', 'layer'], function () {
        form = layui.form;
        layer = layui.layer;
        element = layui.element;
    });
    $(".layui-btn").click(function () {
        var from = $("#fromID").find("option:selected").text();
        var to = $("#toID").find("option:selected").text();
        if (from == to) {
            layer.msg("源数据源和目标数据不能一致");
            return;
        }
        var notice = "您确认将 <span style='color:red;'>" + from + "</span> 流程复制到 <span style='color:red;'>" + to +"</span> 吗?";
        layer.confirm(notice, {
            btn: ['我要复制', '不小心点错了'],title:"复制确认"
        }, function () {
            $("#myForm").submit();
        }); 
    });
</script>